#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int timeRequiredToBuy(vector<int>& tickets, int k) {
    int n = tickets.size();
    int res = 0;
    for (int i = 0; i < n; ++i)
    {
        if (i <= k)
        {
            res += min(tickets[i], tickets[k]);
        }
        else
        {
            res += min(tickets[i], tickets[k] - 1);
        }
    }

    return res;

}

bool CheckPermutation(string s1, string s2) {
    if (s1.size() != s2.size())
    {
        return false;
    }

    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());

    return s1 == s2;
}




int main()
{
    vector<int> tickets = { 2, 3, 2 };
    int sum1 = timeRequiredToBuy(tickets, 2);
    cout << sum1 << endl;

    string s1 = "abc";
    string s2 = "bca";

    if (CheckPermutation(s1, s2))
    {
        cout << "true" << endl;

    }
    else
    {
        cout << "false" << endl;
    }

	return 0;
}